package com.mf.controller;

import com.mf.result.Result;
import com.mf.service.CalculateService.*;
import com.mf.vo.CapitalVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: lmf
 * @Create: 2024/9/9 20:34
 * Description:  第四版在第三版的基础上修改卖出逻辑
 */
@RestController
@RequestMapping("/calculate4")
public class Calculate4Controller {
    @Resource
    private Calculate4Service calculate4Service;

    @Resource
    private Calculate5Service calculate5Service;

    @Resource
    private CalculateService6 calculateService6;

    @Resource
    private CalculateService7 calculateService7;

    @Resource
    private CalculateService8 calculateService8;

    /**
     * 计算卖出日期
     */
    @RequestMapping("/calculateSellDate")
    public Result<List<CapitalVo>> calculateSellDate() {
        return Result.success(calculate4Service.calculateSellDate());
    }

    /**
     * 计算单个股票代码的买入位置
     */
    @GetMapping("/singleCalculate")
    public void singleCalculate(@RequestParam("md") String md) {
        calculate4Service.singleCalculate(md);
    }


    /**
     * 计算股票代码的买入位置
     */
    @GetMapping("/calculateByDm")
    public void calculate(@RequestParam("md") String md) {
        calculate4Service.calculate(md);
    }


    /**
     * =================5==========================
     * 计算卖出日期
     */
    @RequestMapping("/calculateSellDate5")
    public Result<List<CapitalVo>> calculateSellDate5(@RequestParam("copies") int copies) {
        return Result.success(calculate5Service.calculateSellDate(copies));
    }

    /**
     * 计算单个股票代码的买入位置
     */
    @GetMapping("/singleCalculate5")
    public void singleCalculate5(@RequestParam("md") String md) {
        calculate5Service.singleCalculate(md);
    }

    /**
     * 计算股票代码的买入位置
     */
    @GetMapping("/calculateByDm5")
    public void calculate5(@RequestParam("md") String md) {
        calculate5Service.calculate(md);
    }



    /**
     * =================6==========================
     * 计算卖出日期
     */
    @RequestMapping("/calculateSellDate6")
    public Result<List<CapitalVo>> calculateService6(@RequestParam("copies") int copies) {
        return Result.success(calculateService6.calculateSellDate(copies));
    }

    /**
     * 计算单个股票代码的买入位置
     */
    @GetMapping("/calculateService6")
    public void singleCalculate6(@RequestParam("md") String md) {
        calculateService6.singleCalculate(md);
    }

    /**
     * 计算股票代码的买入位置
     */
    @GetMapping("/calculateByDm6")
    public void calculate6(@RequestParam("md") String md) {
        calculateService6.calculate(md);
    }

    /**
     * =================7==========================
     * 计算卖出日期
     */
    @RequestMapping("/calculateSellDate7")
    public Result<List<CapitalVo>> calculateService7(@RequestParam("copies") int copies) {
        return Result.success(calculateService7.calculateSellDate(copies));
    }

    /**
     * 计算单个股票代码的买入位置
     */
    @GetMapping("/calculateService7")
    public void singleCalculate7(@RequestParam("md") String md) {
        calculateService7.singleCalculate(md);
    }

    /**
     * 计算股票代码的买入位置
     */
    @GetMapping("/calculateByDm7")
    public void calculate7(@RequestParam("md") String md) {
        calculateService7.calculate(md);
    }

    /**
     * =================8==========================
     * 计算卖出日期
     */
    @RequestMapping("/calculateSellDate8")
    public Result<List<CapitalVo>> calculateService8(@RequestParam("copies") int copies) {
        return Result.success(calculateService8.calculateSellDate(copies));
    }

    /**
     * 计算单个股票代码的买入位置
     */
    @GetMapping("/calculateService8")
    public void singleCalculate8(@RequestParam("md") String md) {
        calculateService8.singleCalculate(md);
    }

    /**
     * 计算股票代码的买入位置
     */
    @GetMapping("/calculateByDm8")
    public void calculate8(@RequestParam("md") String md) {
        calculateService8.calculate(md);
    }
}
